Investment = new Object();

var investmentId = null;
var formpanel;
var fundDate;
var inv_disableDates = [];

var investments_store = Ext.create('Ext.data.Store', {
	fields : [ 'id', 'invenstmentCode', 'amount', 'fundTransferType', 'status', 'requestDate', 'customer', 'depositTo', 'fullRedemption', 'fullRedemptionDate',
			'monthlyInterestRequired', 'investmentinterestType', 'monIntStartDate', 'nameOfBank', 'branch', 'chequeNo', 'chequeDate', 'accountNo', 'recodUser', 'customer_name',
			'fund_id', 'confirmDate', 'unitPrice', 'noOfUnits' ]
});
var customer_account_store = Ext.create('Ext.data.Store', {
	fields : [ 'accountNo', 'branch', 'nameOfBank', 'customer', 'id' ]
});
var customer_store = Ext.create('Ext.data.Store', {
	fields : [ 'id', 'code', 'title', 'initials', 'surname', 'denotedByInitials', 'nicPassport', 'customerType', 'accountType', 'residential', 'fmId', 'correspondingAddress',
			'generalAddress', 'phone', 'fax', 'corresEmail', 'corresFax', 'corresPost', 'corresInst', 'bankInstrution', 'organizationName', 'businessRegNo', 'businessAddress' ]
});

var inv_fund_store = Ext.create('Ext.data.Store', {
	fields : [ 'id', 'name', 'code', 'unitValue', 'updateDate' ]
});

Investment.getUnitDetails = function() {

	return Ext.create('Ext.form.FieldSet', {
		title : 'Fund / Unit Details',
		id : 'FS_UnitDetails',
		defaults : {
			anchor : '100%'
		},
		items : [ {
			xtype : 'combo',
			fieldLabel : 'Fund',
			anchor : '70%',
			id : 'fund',
			labelWidth : 160,
			store : inv_fund_store,
			valueField : 'id',
			displayField : 'code',
			emptyText : 'Select a Fund...',
			isLoaded : false,
			editable : false,
			name : 'fund_id',
			tpl : Ext.create('Ext.XTemplate', '<tpl for=".">', '<div class="x-boundlist-item">{code} - {name}</div>', '</tpl>'),
			displayTpl : Ext.create('Ext.XTemplate', '<tpl for=".">', '{code} - {name}', '</tpl>'),
			listeners : {
				expand : function(combo, opt) {
					if (!combo.isLoaded) {
						Ext.Ajax.request({
							url : 'getFundVsUnitValue.action',
							success : function(response) {
								var obj = Ext.decode(response.responseText);
								combo.getStore().loadRawData(obj.fundDtos);
								combo.isLoaded = true;
							}
						});
					}
				},
				change : function(combo, record, index) {
					if (combo.getValue() == "" || combo.getValue() == "&nbsp;" || combo.getValue == 0) {
						combo.setValue(null);
					}
				}
			},
			listConfig : {
				listeners : {
					itemclick : function(list, record) {
						if (record.get('unitValue') != null) {
							Ext.getCmp('unit_value').setValue(Ext.util.Format.number(record.get('unitValue'), '0,000.00'));
							if (Ext.getCmp('amount').getValue() != null || Ext.getCmp('amount').getValue() != "") {
								var amount = parseFloat(Ext.getCmp('amount').getValue().replace(/,/g, ''));
								var unitPrice = record.get('unitValue');
								var unit = amount / unitPrice;
								Ext.getCmp('number_of_units').setValue(Ext.util.Format.number(unit, '0,000.00'));
							}
						}
						if (record.get('updateDate') != null) {
							Ext.getCmp('confirmDate').setValue(record.get('updateDate'));
						}
					}
				}
			}
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			items : [ {
				xtype : 'textfield',
				fieldLabel : 'Unit Price',
				readOnly : true,
				labelWidth : 160,
				name : 'unitPrice',
				id : 'unit_value',
				flex : 1.5,
				padding : '0 10 0 0',
				fieldStyle : "text-align:right;",
				maskRe : /[\d\,.]/,
				listeners : {
					blur : function() {
						var upval = this.value.replace(/,/g, '');
						this.setRawValue(Ext.util.Format.number(upval, '0,000.00'));
					},
					render : function() {
						this.setRawValue(Ext.util.Format.number(this.value, '0,000.00'));
					}
				}
			}, {
				xtype : 'textfield',
				fieldLabel : 'As at',
				readOnly : true,
				flex : 1,
				name : 'confirmDate',
				id : 'confirmDate',
				labelWidth : 80,
			} ]
		}, {
			xtype : 'textfield',
			fieldLabel : 'Number Of Units',
			readOnly : true,
			name : 'noOfUnits',
			anchor : '60%',
			id : 'number_of_units',
			labelWidth : 160,
			fieldStyle : "text-align:right;",
			maskRe : /[\d\,.]/,
			listeners : {
				blur : function() {
					var nuval = this.value.replace(/,/g, '');
					this.setRawValue(Ext.util.Format.number(nuval, '0,000.00'));
				},
				render : function() {
					this.setRawValue(Ext.util.Format.number(this.value, '0,000.00'));
				}
			}
		} ]
	});
};

Investment.getBasicDetails = function() {
	return Ext.create('Ext.form.FieldSet', {
		defaults : {
			anchor : '100%'
		},
		items : [ {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			items : [ {
				xtype : 'displayfield',
				fieldLabel : 'Request Date',
				name : 'requestDate',
				labelWidth : 110,
				submitValue : true,
				padding : '0 15 0 0',
				value : Ext.Date.format(new Date(), "d/m/Y"),
				flex : 1
			}, {
				xtype : 'displayfield',
				fieldLabel : 'Status',
				flex : 1,
				submitValue : true,
				name : 'status',
				value : 'INITIAL'
			} ]
		}, {
			xtype : 'combo',
			labelWidth : 110,
			store : customer_store,
			valueField : 'id',
			displayField : 'code',
			fieldLabel : 'Customer <span style="color:red">*</span>',
			anchor : '70%',
			allowBlank : false,
			id : 'customer',
			msgTarget : 'under',
			name : 'customer',
			queryMode : 'local',
			isLoaded : false,
			tpl : Ext.create('Ext.XTemplate', '<tpl for=".">', '<div class="x-boundlist-item">{code} - {surname}</div>', '</tpl>'),
			displayTpl : Ext.create('Ext.XTemplate', '<tpl for=".">', '{code} - {surname}', '</tpl>'),
			listeners : {
				expand : function(combo, opt) {
					if (!combo.isLoaded) {
						Ext.Ajax.request({
							url : 'getCustomer.action',
							success : function(response) {
								var obj = Ext.decode(response.responseText);
								combo.getStore().loadRawData(obj.customerBeans);
								combo.isLoaded = true;
							}
						});
					}
				},
				change : function(list, record) {
					Ext.Ajax.request({
						url : 'getBankAccountByCustomer.action',
						params : {
							"customer_id" : list.getValue()
						},
						success : function(response) {
							var obj = Ext.decode(response.responseText);
							customer_account_store.loadRawData(obj.bankAccounts);
						}
					});
				}
			},
			listConfig : {
				listeners : {
					itemclick : function(list, record) {
						if (record.get('code') != null) {
							Ext.Ajax.request({
								url : 'getBankAccountByCustomer.action',
								params : {
									"customer_id" : record.get('id')
								},
								success : function(response) {
									var obj = Ext.decode(response.responseText);
									Ext.getCmp('bank_account').clearValue();
									customer_account_store.removeAll();
									customer_account_store.loadRawData(obj.bankAccounts);
								}
							});
						}
					}
				}
			}
		}, {
			xtype : 'radiogroup',
			fieldLabel : 'Fund Transfer',
			columns : 4,
			anchor : '70%',
			labelWidth : 110,
			vertical : true,
			items : [ {
				boxLabel : 'RTGS',
				name : 'fundTransferType',
				inputValue : 'R',
				checked : true,
				listeners : {
					change : function(field, newValue, oldValue) {
						if (newValue) {
							Ext.getCmp('bank_account').setDisabled(false);
						}
					}
				}
			}, {
				boxLabel : 'SLIP',
				name : 'fundTransferType',
				inputValue : 'S',
				listeners : {
					change : function(field, newValue, oldValue) {
						if (newValue) {
							Ext.getCmp('bank_account').setDisabled(false);
						}
					}
				}
			}, {
				boxLabel : 'CASH',
				name : 'fundTransferType',
				inputValue : 'T',
				listeners : {
					change : function(field, newValue, oldValue) {
						if (newValue) {
							Ext.getCmp('bank_account').clearValue();
							Ext.getCmp('bank_account').setDisabled(true);
							Ext.getCmp('depositTo').setDisabled(false);
						} else {
							Ext.getCmp('depositTo').setDisabled(true);
							Ext.getCmp('rddb').setValue(true);
						}
					}
				}
			}, {
				boxLabel : 'CHEQUE',
				name : 'fundTransferType',
				inputValue : 'C',
				listeners : {
					change : function(field, newValue, oldValue) {
						if (newValue) {
							Ext.getCmp('bank_account').clearValue();
							Ext.getCmp('bank_account').setDisabled(true);
							Ext.getCmp('chequeForm').show();
							Ext.getCmp('chequeNo').enable(true);
						} else {
							Ext.getCmp('chequeForm').hide();
							Ext.getCmp('chequeNo').disable(true);
						}
					}
				}
			} ]
		}, {
			xtype : 'fieldcontainer',
			defaultType : 'radiofield',
			fieldLabel : 'Deposit To',
			layout : 'hbox',
			id : 'depositTo',
			disabled : true,
			labelWidth : 110,
			items : [ {
				boxLabel : 'Custodian Account',
				name : 'depositTo',
				inputValue : 'D',
				checked : true,
				id : 'rddb',
				padding : '0 24 0 0'
			}, {
				boxLabel : 'CALI Account',
				name : 'depositTo',
				inputValue : 'N',
				id : 'rdntb',
			} ]
		}, {
			xtype : 'fieldset',
			id : 'chequeForm',
			hidden : true,
			padding : '5 0 5 0',
			items : [ {
				xtype : 'fieldcontainer',
				layout : 'hbox',
				items : [ {
					xtype : 'textfield',
					labelWidth : 110,
					fieldLabel : 'Name of Bank',
					padding : '0 15 0 0',
					flex : 1,
					name : 'nameOfBank'
				}, {
					xtype : 'textfield',
					fieldLabel : 'Branch',
					flex : 1,
					name : 'branch'
				} ]
			}, {
				xtype : 'fieldcontainer',
				layout : 'hbox',
				items : [ {
					xtype : 'numberfield',
					fieldLabel : 'Cheque No',
					labelWidth : 110,
					id : 'chequeNo',
					allowBlank : false,
					msgTarget : 'under',
					hideTrigger : true,
					disabled : true,
					keyNavEnabled : false,
					mouseWheelEnabled : false,
					padding : '0 15 0 0',
					flex : 1,
					name : 'chequeNo'
				}, {
					xtype : 'datefield',
					format : 'd/m/Y',
					fieldLabel : 'Cheque Date',
					disabledDays : [ 0, 6 ],
					flex : 1,
					name : 'chequeDate'
				} ]
			} ]
		}, {
			xtype : 'combo',
			fieldLabel : 'Bank Account <span style="color:red">*</span>',
			anchor : '70%',
			store : customer_account_store,
			valueField : 'id',
			displayField : 'accountNo',
			queryMode : 'local',
			allowBlank : false,
			editable : false,
			id : 'bank_account',
			labelWidth : 110,
			msgTarget : 'under',
			name : 'accountNo',
			tpl : Ext.create('Ext.XTemplate', '<tpl for=".">', '<div class="x-boundlist-item">{accountNo} - {nameOfBank} ({branch})</div>', '</tpl>'),
			displayTpl : Ext.create('Ext.XTemplate', '<tpl for=".">', '{accountNo} - {nameOfBank} ({branch})', '</tpl>'),
			listeners : {
				change : function(combo, record, index) {
					if (combo.getValue() == "" || combo.getValue() == "&nbsp;" || combo.getValue == 0)
						combo.setValue(null);
				}
			}
		}, {
			xtype : 'textfield',
			fieldLabel : 'Amount <span style="color:red">*</span>',
			labelWidth : 110,
			minValue : 0,
			anchor : '45%',
			id : 'amount',
			name : 'amount',
			readOnly : false,
			allowBlank : false,
			msgTarget : 'under',
			fieldStyle : "text-align:right;",
			maskRe : /[\d\,.]/,
			listeners : {
				blur : function() {
					var val = this.value.replace(/,/g, '');
					this.setRawValue(Ext.util.Format.number(val, '0,000.00'));
					if (Ext.getCmp('fund').getValue() != null || Ext.getCmp('fund').getValue() == "") {
						var unitPrice = Ext.getCmp('unit_value').getValue();
						var unit = val / unitPrice;
						Ext.getCmp('number_of_units').setValue(Ext.util.Format.number(unit, '0,000.00'));
					}
				},
				render : function() {
					this.setRawValue(Ext.util.Format.number(this.value, '0,000.00'));
				}
			}
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			items : [ {
				xtype : 'checkbox',
				boxLabel : 'Full Redemption',
				name : 'fullRedemption',
				inputValue : '1',
				padding : '0 25 0 0',
				labelWidth : 120,
				listeners : {
					change : function() {
						Ext.getCmp('redemptionDate').setDisabled(!this.getValue());
					}
				}
			}, {
				xtype : 'datefield',
				format : 'd/m/Y',
				submitFormat : 'd/m/Y',
				labelWidth : 110,
				anchor : '60%',
				allowBlank : false,
				msgTarget : 'under',
				id : 'redemptionDate',
				name : 'fullRedemptionDate',
				fieldLabel : 'Redemption Date',
				disabledDays : [ 0, 6 ],
				disabled : true,
				disabledDatesText : 'Holiday'
			} ]
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			items : [ {
				xtype : 'checkbox',
				boxLabel : 'Interest Required',
				name : 'monthlyInterestRequired',
				inputValue : '1',
				labelWidth : 120,
				padding : '0 25 0 0',
				listeners : {
					change : function() {
						Ext.getCmp('redemptionStartDate').setDisabled(!this.getValue());
						Ext.getCmp('iterestType').setDisabled(!this.getValue());
					}
				}
			}, {
				xtype : 'datefield',
				format : 'd/m/Y',
				submitFormat : 'd/m/Y',
				labelWidth : 110,
				anchor : '60%',
				allowBlank : false,
				msgTarget : 'under',
				name : 'monIntStartDate',
				id : 'redemptionStartDate',
				fieldLabel : 'Start Date',
				disabledDays : [ 0, 6 ],
				disabled : true,
				disabledDatesText : 'Holiday'
			} ]
		}, {
			xtype : 'radiogroup',
			fieldLabel : 'Interest Type',
			columns : 4,
			id : 'iterestType',
			anchor : '70%',
			labelWidth : 110,
			vertical : true,
			disabled : true,
			items : [ {
				boxLabel : 'Monthly',
				name : 'investmentinterestType',
				inputValue : 'M',
				checked : true
			}, {
				boxLabel : 'Quarterly',
				name : 'investmentinterestType',
				inputValue : 'Q'
			}, {
				boxLabel : 'Semeanually',
				name : 'investmentinterestType',
				inputValue : 'S'
			}, {
				boxLabel : 'Anually',
				name : 'investmentinterestType',
				inputValue : 'A'
			} ]
		}, {
			xtype : 'textareafield',
			name : 'instructions',
			fieldLabel : 'Instructions',
			labelWidth : 110,
			anchor : '70%',
			height : 50
		} ]
	});
};

Investment.getCenterPanel = function() {

	var unitDetails = Investment.getUnitDetails();
	var basic = Investment.getBasicDetails();

	formpanel = Ext.create('Ext.form.Panel', {
		title : 'Add Investment',
		bodyPadding : 20,
		autoScroll : true,
		frame : true,
		id : 'investment_form',
		defaults : {
			labelWidth : 110,
			anchor : '72%',
		},
		items : [ {
			xtype : 'fieldcontainer',
			items : [ {
				xtype : 'triggerfield',
				emptyText : 'Search Investments',
				triggerCls : 'x-form-search-trigger',
				width : 300,
				name : 'invenstmentCode',
				style : 'float:right;',
				listeners : {
					specialkey : function(field, e) {
						if (e.getKey() == e.ENTER) {
							// Ext.Ajax.request({
							// params : {
							// "investment_code" : field.getValue()
							// },
							// url : 'getInvestmentByCode.action',
							// success : function(response) {
							// var obj = Ext.decode(response.responseText);
							// }
							// });
						}
					}
				},
				onTriggerClick : function() {
					var window = null;
					Ext.Ajax.request({
						url : 'getInitalInvestment.action',
						success : function(response) {
							var obj = Ext.decode(response.responseText);
							investments_store.removeAll();
							investments_store.loadRawData(obj.investmentBeans);
						}
					});
					if (!window) {
						window = Ext.create('Ext.window.Window', {
							title : 'Investments',
							height : 330,
							frame : true,
							width : 500,
							constrain : true,
							resizable : false,
							modal : true,
							layout : {
								type : 'fit'
							},
							items : [ {
								xtype : 'gridpanel',
								defaults : {
									anchor : '100%'
								},
								store : investments_store,
								columns : [ {
									text : 'Code',
									dataIndex : 'invenstmentCode',
									flex : 1
								}, {
									text : 'Name',
									dataIndex : 'customer_name',
									flex : 1.4
								}, {
									text : 'Amount',
									dataIndex : 'amount',
									flex : 1,
									align : 'right'
								} ],
								listeners : {
									itemdblclick : function(dv, record, item, index, e) {
										var data = record.data;
										Investment.setFormFields(data, record);
										window.hide();
									}
								}
							} ]
						});
					}
					;
					if (window.isVisible()) {
						window.hide();
					} else {
						window.show();
					}
				}
			} ]
		}, basic, unitDetails ],
		buttonAlign : 'center',
		buttons : [ {
			text : 'Cancel',
			handler : function() {
				App.Core.removeScreen();
			}
		}, {
			text : 'Reset',
			handler : function() {
				this.up('form').getForm().reset();
				if (App.screenPermiton.getAt(0).data.create == 0)
					Ext.getCmp('save').disable();
				else
					Ext.getCmp('save').enable();
				Ext.getCmp('save').setText('Save');
				Ext.getCmp('confirm').disable();
				Ext.getCmp('reject').disable();
				customer_account_store.removeAll();
				investmentId = null;
			}
		}, {
			text : 'Save',
			id : 'save',
			handler : function() {
				var form = this.up('form').getForm();
				if (form.isValid()) {
					if (investmentId == null) {
						form.url = 'addInvestment.action';
						form.submit({
							success : function(form, action) {
								form.reset();
								investmentId = null;
								Ext.getCmp('save').setText('Save');
								Ext.Msg.alert('Success', 'Saved Successfully');
							},
							failure : function(form, action) {
								Ext.Msg.alert('Failed', action.result.resulteMsg);
							}
						});
					} else {
						form.url = 'updateInvestment.action';
						form.submit({
							params : {
								"investment_id" : investmentId
							},
							success : function(form, action) {
								form.reset();
								investmentId = null;
								Ext.getCmp('save').setText('Save');
								Ext.Msg.alert('Success', 'Updated Successfully');
							},
							failure : function(form, action) {
								Ext.Msg.alert('Failed', action.result.resulteMsg);
							}
						});
					}
				}
			}
		}, {
			text : 'Confirm',
			id : 'confirm',
			disabled : true,
			handler : function() {
				var form = this.up('form').getForm();
				var confirmDate = Ext.getCmp('confirmDate');
				var select_fund = Ext.getCmp('fund');
				if (investmentId != null) {
					if (form.isValid()) {
						if (confirmDate.getValue() != null && select_fund.getValue() != null) {
							form.url = 'confirmInvestment.action';
							form.submit({
								params : {
									"investment_id" : investmentId
								},
								success : function(form, action) {
									form.reset();
									investmentId = null;
									Ext.getCmp('save').setText('Save');
									Ext.Msg.alert('Success', 'Investment Confirmed');
								},
								failure : function(form, action) {
									Ext.Msg.alert('Failed', action.result.resulteMsg);
								}
							});

						} else {
							Ext.Msg.alert('Error', 'Enter the confirmation Details');
						}
					}
				} else {
					Ext.Msg.alert('Info', 'Select the Investment');
				}
			}
		}, {
			text : 'Reject',
			id : 'reject',
			disabled : true,
			handler : function() {
				var form = this.up('form').getForm();
				if (investmentId != null) {
					if (form.isValid()) {
						form.submit({
							url : 'rejectInvestment.action',
							method : 'GET',
							params : {
								"investment_id" : investmentId
							},
							success : function(form, action) {
								form.reset();
								investmentId = null;
								Ext.getCmp('save').setText('Save');
								Ext.Msg.alert('Success', 'Investment Reject');
							},
							failure : function(form, action) {
								Ext.Msg.alert('Failed', action.result.resulteMsg);
							}
						});
					}
				} else {
					Ext.Msg.alert('Info', 'Select the Investment');
				}
			}
		}
		// ,{
		// text : 'Print',
		// handler : function() {
		// if (investmentId != null) {
		// var param = {
		// 'investment' : investmentId
		// };
		// Report.OpenWindowWithPost('ReportCallerServlet/unit_certificate',
		// "width=1000, height=600, left=100, top=100,resizable=yes,
		// scrollbars=yes", "NewFile", param);
		// }
		// }
		// }
		],
		listeners : {
			render : function(p) {
				Ext.Ajax.request({
					url : 'getBankHoliday.action',
					success : function(response) {
						var obj = Ext.decode(response.responseText);
						HolidayCalendar.holiday_store.removeAll();
						HolidayCalendar.holiday_store.loadRawData(obj.calendarDtos);
						HolidayCalendar.holiday_store.each(function(record) {
							inv_disableDates.push(record.get('date'));
						});
						Ext.getCmp('redemptionDate').setDisabledDates(inv_disableDates);
						Ext.getCmp('redemptionStartDate').setDisabledDates(inv_disableDates);
					}
				});

				if (App.screenPermiton.getAt(0).data.create == 0)
					Ext.getCmp('save').disable();
				else
					Ext.getCmp('save').enable();

			}
		}
	});
	return formpanel;
};

function filter_customer_account(combo, record, index) {

	var customer_id = combo.getValue();
	var customercode = (new String(combo.getRawValue())).split('-');
	Ext.getCmp('inv_code').setValue(customercode[0].concat("_" + Ext.Date.format(new Date(), "d/m/Y")));
	Ext.getCmp('bank_account').clearValue();
	customer_account_store.clearFilter(true);
	customer_account_store.filter([ {
		property : 'customer_id',
		value : customer_id
	}, {
		filterFn : function(item) {
			return item.get("customer_id") == customer_id;
		}
	} ]);
	customer_account_store.loadData(customer_account_store.data, false);

};

Investment.setFormFields = function(data, record) {
	var formPanl = Ext.getCmp('investment_form');
	investmentId = data.id;
	Ext.Ajax.request({
		url : 'getFundVsUnitValue.action',
		success : function(response) {
			var obj = Ext.decode(response.responseText);
			inv_fund_store.loadRawData(obj.fundDtos);
		}
	});
	Ext.Ajax.request({
		url : 'getCustomer.action',
		success : function(response) {
			var obj = Ext.decode(response.responseText);
			customer_store.loadRawData(obj.customerBeans);
			Ext.getCmp('customer').isLoaded = true;
		}
	});

	if (data.status == "INITIAL") {
		if (App.screenPermiton.getAt(0).data.create == 0)
			Ext.getCmp('save').disable();
		else
			Ext.getCmp('save').enable();

		if (App.screenPermiton.getAt(0).data.confirm == 0)
			Ext.getCmp('confirm').disable();
		else
			Ext.getCmp('confirm').enable();

		if (App.screenPermiton.getAt(0).data.reject == 0)
			Ext.getCmp('reject').disable();
		else
			Ext.getCmp('reject').enable();
		Ext.getCmp('save').setText('Update');
		formPanl.getForm().loadRecord(record);
	} else if (data.status == "CONFIRM") {
		Ext.getCmp('save').disable();
		Ext.getCmp('confirm').disable();
		Ext.getCmp('reject').disable();
		formPanl.getForm().loadRecord(record);
	} else {
		Ext.getCmp('save').disable();
		Ext.getCmp('reject').disable();
		Ext.getCmp('confirm').disable();
		formPanl.getForm().loadRecord(record);
	}

};

Investment.setLoadFormRec = function(data) {
	var formPanl = Ext.getCmp('investment_form');
	investmentId = data.id;
	formPanl.getForm().load(data);

};

// // {
// xtype : 'datefield',
// labelWidth : 160,
// anchor : '50%',
// id : 'confirmDate',
// fieldLabel : 'Expecting Unit Issue Date',
// format : 'd/m/Y',
// name : 'confirmDate',
// flex : 1
// },
